setwd("/Users/davidcarter/Dropbox/Systemic Crisis Rep/")


library(readstata13);library(foreign);library(lme4)


data<-read.dta13("systemic_data_compiled.dta") 



yrs<-seq(1816,2002)


data<-data[data$year< 2003,]


fixef<-lm( make_claim_onset_f ~ as.factor(year)-1,data)

plot(1816:2002,coef(fixef),type="n",axes=F,xlab="",ylab="Year Effect",ylim=c(-.05,.3))



points(1816:2002,coef(fixef),pch=16,col="grey")





for(i in 1:length(yrs)){
  
  
  se<-sqrt(vcov(fixef)[i,i])
  
  lines(c(yrs[i],yrs[i]), c(coef(fixef)[i] - 1.96*se,coef(fixef)[i] + 1.96*se ),col="grey" )
  
  
  if(coef(fixef)[i] - 1.96*se > 0){ 
    
    points(yrs[i],  coef(fixef)[i], col="dark red",pch=16)
    
    
    lines(c(yrs[i],yrs[i]), c(coef(fixef)[i] - 1.96*se,coef(fixef)[i] + 1.96*se ),col="dark red" )
    
    
    
    }
  
  
  
}



axis(2)

axis(1,at=c(1816,1848,1866,1871,1914,1938,1991,2012))

axis(1, at = seq(1816, 2000, by = 4), las=2)
